#ifndef __OCLIP_CACHE_H__
#define __OCLIP_CACHE_H__

#include "misc/oXmlItemCache.h"

class oClipDef;

/** @brief Load frame animations from ".frame" files and cache them. */
class oDLL oClipCache: public oXmlItemCache<oClipDef>
{
public:
	/** A clip str is like "loli.clip|0", file name + "|" + clip index.
	 Load a new clip file or get it from cache,
	 then create a new CCsprite instance with certain clip.
	*/
	CCSprite* loadSprite(const char* clipStr);
	/** Singleton method as oClipCache::sharedCache(). */
	SHARED_CACHE_FUNC(oClipCache)
protected:
	oClipCache(){}
	virtual void beforeParse( const char* filename );
	virtual void afterParse( const char* filename );
	virtual void textHandler( void *ctx, const char *s, int len );
	virtual void startElement( void *ctx, const char *name, const char **atts );
	virtual void endElement( void *ctx, const char *name );
};

#define oSharedClipCache oClipCache::sharedCache()

#endif